﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace _047.任务
{
	internal class Program
	{
		static void Main(string[] args)
		{
			// 任务是放在线程池管理的 是后台线程
			//TaskFactory tf = new TaskFactory();
			// 启动任务
			//Task t = tf.StartNew(Test);

			// 构建任务对象
			//Task task = new Task(Test);
			//task.Start();

			//Thread.Sleep(5000);


			// 连续任务
			Task t1 = new Task(FirstDownLoad);
			Task t2 = t1.ContinueWith(SecondAlert);
			t1.Start();
			Thread.Sleep(5000);
		}
		static void Test()
		{
			for (int i = 0; i < 100000; i++)
			{
				Console.WriteLine("A");
			}
		}

		// 连续任务
		static void FirstDownLoad()
		{
			Console.WriteLine("FirstDownLoading ...");
			Thread.Sleep(2000);
		}
		static void SecondAlert(Task t)
		{
			Console.WriteLine("什么时候下载完成");
		}
	}
}
